﻿#region Usings

using OxyPlot;
using OxyPlot.Series;

#endregion

namespace DataInterpolator.Utility
{
   public class ShiftedTwoColorAreaSeries : TwoColorAreaSeries
   {
      private double _XScale = 1.0;

      public double XScale
      {
         get
         {
            return _XScale;
         }
         set
         {
            _XScale = value;
         }
      }

      private double _XShift = 0.0;

      public double XShift
      {
         get
         {
            return _XShift;
         }
         set
         {
            _XShift = value;
         }
      }

      private double _YScale = 1.0;

      public double YScale
      {
         get
         {
            return _YScale;
         }
         set
         {
            _YScale = value;
         }
      }

      private double _YShift = 0.0;

      public double YShift
      {
         get
         {
            return _YShift;
         }
         set
         {
            _YShift = value;
         }
      }

      public string XLabel { get; set; }
      public string YLabel { get; set; }

      public override TrackerHitResult GetNearestPoint(ScreenPoint point, bool interpolate)
      {
         TrackerHitResult result = base.GetNearestPoint(point, interpolate);

         if (result != null)
         {
            result.Text = StringHelper.Format(ActualCulture,
                                              TrackerFormatString,
                                              result.Item,
                                              Title,
                                              XLabel ?? (XAxis.Title ?? DefaultXAxisTitle),
                                              result.DataPoint.X * XScale + XShift,
                                              YLabel ?? (YAxis.Title ?? DefaultYAxisTitle),
                                              result.DataPoint.Y * YScale + YShift);
         }

         return result;
      }
   }
}
